package cn.outmaneuver.outman.web.basic.advice;
/**
 * Copyright 2023-2023 by DongYaoMing. All Rights Reserved.
 */

import cn.outmaneuver.outman.web.basic.domain.response.StandardResult;
import org.springframework.web.bind.annotation.*;

import org.springframework.validation.BindException;

/**
 * ExceptionHandlerAdvice
 * <p>统一异常处理拦截器</p>
 *
 * @author DongYaoMing
 * @version 1.0
 * @date 2023/09/27
 */
@RestControllerAdvice
public class GlobalExceptionHandlerAdvice {

    @ExceptionHandler(value = BindException.class)
    public StandardResult BindExceptionHandler(BindException e) {
        return StandardResult.fail("999999", e.getMessage());
    }

    @ExceptionHandler(value = RuntimeException.class)
    public StandardResult RuntimeExceptionHandler(RuntimeException e) {
        return StandardResult.fail("999999", e.getMessage());
    }

    @ExceptionHandler(value = Exception.class)
    public StandardResult ExceptionHandler(Exception e) {
        return StandardResult.fail("999999", e.getMessage());
    }
}
